package com.ruoyi.parkinglot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.parkinglot.domain.ParkSpot;
import com.ruoyi.parkinglot.domain.vo.ParkingStatusVO;
import com.ruoyi.parkinglot.mapper.ParkSpotMapper;
import com.ruoyi.parkinglot.service.ParkSpotService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;

/**
* @author 31713
* @description 针对表【park_spot(泊位表 - 用于管理停车位信息及使用状态)】的数据库操作Service实现
* @createDate 2025-02-11 13:43:45
*/
@Service
public class ParkSpotServiceImpl extends ServiceImpl<ParkSpotMapper, ParkSpot>
    implements ParkSpotService {

    @Override
    public List<ParkingStatusVO> selectParkingStatus() {
        LambdaQueryWrapper<ParkSpot> wrapper = new LambdaQueryWrapper<>();
        wrapper.orderByDesc(ParkSpot::getSpotId);
        return this.list(wrapper).stream().map(parkSpot -> {
            ParkingStatusVO vo = new ParkingStatusVO();
            BeanUtils.copyProperties(parkSpot, vo);
            return vo;
        }).collect(Collectors.toList());
    }
}




